<!doctype html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script>
      run(async function () {
        const { directLine, store } = testHelpers.createDirectLineEmulator();

        WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat'));

        await pageConditions.uiConnected();

        await directLine.emulateIncomingActivity({
          attachments: [
            {
              content: {
                type: 'AdaptiveCard',
                $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
                version: '1.5',
                speak: 'Hello, World!',
                body: [
                  {
                    type: 'TextBlock',
                    text: 'Hello, World!'
                  }
                ]
              },
              contentType: 'application/vnd.microsoft.card.adaptive'
            },
            {
              content: {
                type: 'AdaptiveCard',
                $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
                version: '1.5',
                speak: 'Hello, World!',
                body: [
                  {
                    type: 'Input.Text',
                    id: 'name',
                    label: 'What is your full name',
                    placeholder: 'For example, John Doe',
                    inlineAction: {
                      type: 'Action.Submit',
                      title: 'Submit'
                    }
                  }
                ]
              },
              contentType: 'application/vnd.microsoft.card.adaptive'
            }
          ]
        });

        await pageConditions.numActivitiesShown(1);

        const [firstAdaptiveCard, secondAdaptiveCard] = Array.from(document.querySelectorAll('.ac-adaptiveCard'));

        expect(firstAdaptiveCard.getAttribute('aria-label')).toBeTruthy();
        expect(firstAdaptiveCard.getAttribute('role')).toBe('figure');

        expect(secondAdaptiveCard.getAttribute('aria-label')).toBeTruthy();
        expect(secondAdaptiveCard.getAttribute('role')).toBe('form');
      });
    </script>
  </body>
</html>
